<?php
class PlaybillAction extends BaseAction{
	/**
	 * Show all bills
	 */
	public function index(){
		$Playbill = M("Playbill");
		$Content = M("Content");
		$selectbills = $Playbill->select();
		foreach ($selectbills as $key => $value) {
			$contentname = $Content->where("content_id=".$value["bill_content"])->find();
			$bill[] = $contentname["content_title"];
			$bill[] = $value;
			$bills[] = $bill;
			unset($bill); 
		}
		$this->assign('bills',$bills);
		$this->display();
	}
	/**
	 * Update a bill
	 */
	public function update(){
		$Playbill = M("Playbill");
		if ($_GET["action"] == 'show' && $_GET['billid']) {
			$data['bill_id'] = $_GET['billid'];
			$data['bill_show'] = 1;
			$Playbill -> data($data)->save();
			$this->assign('waitSecond',15);
			$this->assign('jumpUrl','index');
			$this->success('成功改为首页显示');
		}elseif ($_GET["action"] == 'close' && $_GET['billid']){
			$data['bill_id'] = $_GET['billid'];
			$data['bill_show'] = 0;
			$Playbill -> data($data)->save();
			$this->assign('waitSecond',15);
			$this->assign('jumpUrl','index');
			$this->success('成功改为首页不显示');
		}else {
			$this->assign('waitSecond',15);
			$this->assign('jumpUrl','index');
			$this->error('参数不合法');
		}
	}
	/**
	 * Delete a bill
	 */
	public function delete(){
		$Playbill = M("Playbill");
		if ($_GET['billid'] && intval($_GET['billid'])) {
			$data = $_GET['billid'];
			$Playbill ->where('bill_id='.$data)->delete();
			$this->assign('waitSecond',15);
			$this->assign('jumpUrl','index');
			$this->success('成功删除该图片的置顶');
		}else {
			$this->assign('waitSecond',15);
			$this->assign('jumpUrl','index');
			$this->error('参数不合法');
		}
	}
}
?>